import os


def main():
    with open("4.txt", "a+", encoding='UTF-8', newline="") as f:
        gamelists = []
        for root, dirs, files in os.walk(r"W:\3ds\hsgame6"):
            gamelists = dirs
            break
        print(gamelists, len(gamelists))
        for game in gamelists:
            f.write(game)
            f.write("\n")


def readfile():
    with open("1.txt", "r", encoding='UTF-8') as f:
        ns = []
        names = f.readlines()
        for n in names:
            ns.append(str(n).strip())

        nss = set(sorted(ns, key=lambda x: x.encode('utf-8')))
        print(len(nss))
        print(nss)
        return list(nss)


if __name__ == "__main__":
    main()
    #  readfile()
